-
Notifications
You must be signed in to change notification settings - Fork 8.3k
drivers: can: mcux: flexcan: move to per-instance message buffer configuration #99483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
9e4b937 to
d8b2c9b
Compare
Fix various formatting issues in NXP device tree files including: - Inconsistent indentation in multi-line interrupt and pll-clocks arrays - Missing spaces around assignment operators - Inconsistent blank line spacing between device tree nodes Also update copyright header in nxp_k6x.dtsi. Signed-off-by: William Tang <william.tang@nxp.com>
Add the `nxp,max-mb` and `nxp,max-mb-fd` device tree property to all NXP FlexCAN controller nodes across various SoC families to specify the maximum number of 8-byte and 64-byte payload message buffers supported by each FlexCAN instance. This change updates device tree source files for multiple NXP SoC families including Kinetis K6x, RT10xx, RT11xx, RT118x, MCX, S32K, S32Z series, and i.MX8MP/i.MX93. The property values are set based on hardware specifications for each specific FlexCAN instance. This property addition ensures proper resource allocation and prevents buffer overflow issues in FlexCAN driver implementations. Signed-off-by: William Tang <william.tang@nxp.com>
d8b2c9b to
205defb
Compare
| [FLEXCAN_INST_RX_MB(id)] = {0}; \ | ||
| \ | ||
| static struct mcux_flexcan_tx_callback flexcan_tx_cbs_##id \ | ||
| [FLEXCAN_INST_TX_MB(id)] = {0}; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just query, do we need to consider the case that FLEXCAN_INST_RX_MB(id) or FLEXCAN_INST_TX_MB(id) is 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In previous, Kconfig symbol CAN_MAX_FILTER is confined to be greater than 0, but there was no constraint that MCUX_FLEXCAN_MAX_TX not be 0.
If MCUX_FLEXCAN_MAX_TX is 0, compiler will report following warning
zephyrproject/zephyr/drivers/can/can_mcux_flexcan.c:1041:32: warning: array subscript 'alloc' is outside the bounds of an interior zero-length array 'struct mcux_flexcan_tx_callback[0]' [-Wzero-length-bounds]
1041 | function = data->tx_cbs[alloc].function;
For safety, I think it would be better to confine FLEXCAN_INST_TX_MB(id) and FLEXCAN_INST_RX_MB(id) greater than 0.
This change refactors the FlexCAN driver to use per-instance message buffer configuration instead of global Kconfig options. The driver now calculates message buffer allocation at compile time based on device tree properties for each FlexCAN instance. Key changes: - Remove global CAN_MAX_MB Kconfig option and associated range constraint - Add max_mb, rx_mb, and tx_mb fields to mcux_flexcan_config structure - Move callback arrays and atomic allocation bitmaps from static global arrays to per-instance static arrays generated by macros - Update data structure to use pointers to per-instance arrays instead of fixed-size embedded arrays - Add compile-time validation to ensure sufficient message buffers are available for required RX filters and RX filters greater than 0 This approach allows different FlexCAN instances to have different message buffer configurations based on their hardware capabilities and device tree settings, improving memory efficiency and flexibility. The change maintains backward compatibility while enabling better resource utilization across different SoC variants. Fixes zephyrproject-rtos#92798 Signed-off-by: William Tang <william.tang@nxp.com>
205defb to
ee6a72b
Compare
|



This change refactors the FlexCAN driver to use per-instance message buffer configuration instead of global Kconfig options. The driver now calculates message buffer allocation at compile time based on device tree properties for each FlexCAN instance.
Key changes:
This approach allows different FlexCAN instances to have different message buffer configurations based on their hardware capabilities and device tree settings, improving memory efficiency and flexibility. The change maintains backward compatibility while enabling better resource utilization across different SoC variants.
Fixes #92798